import { Injectable } from '@angular/core'
import { IFormItem, ChanCodeValue } from '@shared/interfaces/common'
import { WXChannel, ALPChannel } from '@shared/interfaces/acquirer'
import { deepCopy } from '@delon/util'
import { CurrencyService } from '@shared/services/currency.service'
import { forkJoin } from 'rxjs'

@Injectable()
export class QrChannelService {

  wxFormItems: IFormItem[] = []

  alipayFormItems: IFormItem[] = []

  currencyOptions = []
  currencyCodeOptions = []

  constructor(
    public currencyService: CurrencyService,
  ) { }

  // initCurrencyOptions(): void {
  //   forkJoin(
  //     this.currencyService.getCurrencies(),
  //     this.currencyService.getCurrenciesStrValue(),
  //   ).subscribe(value => {
  //     const [ currencies, currencyCodes ] = value
  //     this.currencyOptions = currencies
  //     this.currencyCodeOptions = currencyCodes
  //     this.initWXFormItems()
  //     this.initALPFormItems()
  //   })
  // }
  // generateValidateRules(chanCode: string, channel?: WXChannel | ALPChannel): {[key: string]: any} {
  //   switch (chanCode) {
  //     case ChanCodeValue.WXP:
  //       return genWXValidateRoles(channel)
  //     case ChanCodeValue.ALP:
  //       return genALPValidateRoles(channel)
  //     default:
  //       return genWXValidateRoles(channel)
  //   }
  // }

  // generateFormItems(chanCode: string): IFormItem[] {
  //   switch (chanCode) {
  //     case ChanCodeValue.WXP:
  //       return [this.chanCodeFormItem, ...deepCopy(this.wxFormItems)]
  //     case ChanCodeValue.ALP:
  //       return [this.chanCodeFormItem, ...deepCopy(this.alipayFormItems)]
  //     default:
  //       return [this.chanCodeFormItem]
  //   }
  // }
  // initWXFormItems(): void {
  //   this.wxFormItems = genWXFormItems(this.currencyOptions, this.handleChanMerIdChange.bind(this))
  // }

  // initALPFormItems(): void {
  //   this.alipayFormItems = genALPFormItems(this.currencyOptions, this.currencyCodeOptions)
  // }
}
